package top.lidee.module.backendApi.twice.third.wechat;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import top.lidee.common.dto.AccountInfo;
import top.lidee.common.service.twice.third.wechat.WechatPayTyshService;
import top.lidee.common.util.TokenUtil;
import top.lidee.framework.enums.CommonExceptionEnum;
import top.lidee.framework.result.ResponseResult;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 张一恒
 * @version 1.0
 * @description: 微信 特约商户进件（提交申请单）
 * @date 2024/10/18 14:40
 */
@Api(tags = "微信 特约商户进件（提交申请单）")
@RestController
@AllArgsConstructor
@RequestMapping(value = "/backendApi/wechatPay/tysh")
public class WechatPayTyshController {

    private final WechatPayTyshService wechatPayTyshService;

    /**
     * 特约商户进件（提交申请单）
     * storeId:店铺id
     */
    @RequestMapping(value = "/wxIncomingPartsTy/{storeId}", method = RequestMethod.GET)
    @ApiOperation(value = "特约商户进件（提交申请单）")
    public ResponseResult wxIncomingPartsTy(@PathVariable("storeId") Integer storeId,
                                          HttpServletRequest request) {
        String token = request.getHeader("Access-Token");
        AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
        if (accountInfo == null) {
            return ResponseResult.errorResult(CommonExceptionEnum.NOAUTH);
        }
        ResponseResult responseResult = wechatPayTyshService.wxIncomingPartsTy(storeId,accountInfo);
        return responseResult;
    }


}
